package com.hiwhitley.chapter09;

/**
 * Created by hiwhitley on 17-2-20.
 */
public class IsPalindrome {
    public boolean isPalindrome(int n) {
        if (n == Integer.MIN_VALUE) {
            return false;
        }

        n = Math.abs(n);
        int help = 1;
        while (n / help >= 10) {
            help *= 10;
        }

        while (n != 0) {
            if (n / help != n % 10) {
                return false;
            }

            n = (n % help) / 10;
            help /= 100;
        }

        return true;
    }
}
